// DlgBarQuickConn.cpp : implementation file
//

#include "stdafx.h"
#include "MyFtp.h"
#include "MainFrm.h"
#include "DlgBarQuickConn.h"


// CDlgBarQuickConn dialog

IMPLEMENT_DYNAMIC(CDlgBarQuickConn, CDialogBar)

CDlgBarQuickConn::CDlgBarQuickConn()
: m_szHost(_T("172.31.3.70"))
, m_szUser(_T("reader"))
, m_szPass(_T("1111"))
, m_nPort(999)
{

}

CDlgBarQuickConn::~CDlgBarQuickConn()
{
}

void CDlgBarQuickConn::DoDataExchange(CDataExchange* pDX)
{
	CDialogBar::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT_HOST, m_szHost);
	DDX_Text(pDX, IDC_EDIT_USERNAME, m_szUser);
	DDX_Text(pDX, IDC_EDIT_PASSWORD, m_szPass);
	DDX_Text(pDX, IDC_EDIT_PORT, m_nPort);
	DDV_MinMaxUInt(pDX, m_nPort, 0, 65535);
}


BEGIN_MESSAGE_MAP(CDlgBarQuickConn, CDialogBar)
	ON_MESSAGE(WM_INITDIALOG, OnInitDialog)
	ON_BN_CLICKED(IDC_BUTTON_QUICK_CONNECT, &CDlgBarQuickConn::OnBnClickedButtonQuickConnect)
	ON_UPDATE_COMMAND_UI(IDC_BUTTON_QUICK_CONNECT, OnUpdateButton)
END_MESSAGE_MAP()


// CDlgBarQuickConn message handlers
LRESULT CDlgBarQuickConn::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
      LRESULT ret = HandleInitDialog(wParam, lParam);
      if(!UpdateData(FALSE))
	  {
             TRACE0("Warning, Unalbe to init update.\n");
      }
      // Add Code here
      return ret;
} 		
void CDlgBarQuickConn::OnBnClickedButtonQuickConnect()
{
	UpdateData(TRUE);

	CMainFrame *pMainFrame = (CMainFrame *)GetParentFrame();

	if(pMainFrame != NULL)
	{
		pMainFrame->OnConnect(m_szHost, m_nPort, m_szUser, m_szPass);
	}
}

void CDlgBarQuickConn::OnUpdateButton(CCmdUI * pCmdUI)
{
     pCmdUI -> Enable(TRUE);
}